package com.jiafa.wjxt.service.impl;

import com.jiafa.wjxt.entity.TUser;
import com.jiafa.wjxt.mapper.TUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

/**
 * Created by jiafa
 * on 2021/5/31 20:35
 */
@Service
public class CustomUserServiceImpl implements UserDetailsService {
    @Autowired
    TUserMapper tUserMapper;

    @Override
    public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException {
        if(s == null){
            throw new UsernameNotFoundException("用户名不存在");
        }
        TUser tUser = tUserMapper.loadUserByUsername(s);
        return tUser;
    }
}
